//
//  MeiYanViewController.m
//  bluetooth
//
//  Created by 周季阳 on 15/7/2.
//  Copyright (c) 2015年 switch. All rights reserved.
//

#import "MeiYanViewController.h"
#import "UIViewAdditions.h"
#import "MeiYanTableViewCell.h"
#import "WaterViewController.h"
#import "MaterialViewController.h"
#import "AppDelegate.h"
#import "ShopViewController.h"
@interface MeiYanViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *zTabelView;
}

@end

@implementation MeiYanViewController
@synthesize zArrayData,zArrayTitle;
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initNav];
    navTitle.text = @"美颜膜方";
    self.view.backgroundColor = [self colorWithHexString:@"#F5F5F5"];
    [self createUI];
    
}
#pragma mark - initUI
-(void)createUI{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, navView.bottom+10, SCREEN_WIDTH-10, 35)];
    label.text = @"请根据个人情况选择面膜原料，如果是固体原料，请将原料榨汁";
    label.textAlignment = NSTextAlignmentLeft;
    label.font = [UIFont systemFontOfSize:14];
    label.textColor = [UIColor blackColor];
    label.numberOfLines = 2;
    [self.view addSubview:label];
   
    zTabelView = [[UITableView alloc] initWithFrame:CGRectMake(0,label.bottom+5, SCREEN_WIDTH, SCREEN_HEIGHT-navView.frame.size.height-10-30-10)];
    zTabelView.backgroundColor = [UIColor clearColor];
    zTabelView.separatorStyle = UITableViewCellSeparatorStyleNone;
    zTabelView.delegate = self;
    zTabelView.dataSource = self;
    zTabelView.bounces = NO;
    [self.view addSubview:zTabelView];
    
    zArrayData = [[NSMutableArray alloc]initWithObjects:@"美颜膜方_03",@"美颜膜方_06",@"美颜膜方_08",@"美颜膜方_10",@"美颜膜方_12",@"美颜膜方_14",@"美颜膜方_16",@"美颜膜方_18",@"美颜膜方_20",@"美颜膜方_22",@"美颜膜方_24",@"美颜膜方_26", nil];
    
    zArrayTitle = [[NSMutableArray alloc]initWithObjects:@"牛奶",@"蜂蜜",@"红酒",@"淘米水",@"黄瓜",@"西红柿",@"苹果",@"猕猴桃",@"荔枝",@"火龙果",@"草莓",@"苦瓜", nil];
}

#pragma mark - UitableView delegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return [zArrayTitle count];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MeiYanTableViewCell *cell = [[MeiYanTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    
    cell.zTitle.text = [zArrayTitle objectAtIndex:indexPath.row];
    cell.zImageView.image = [UIImage imageNamed:[zArrayData objectAtIndex:indexPath.row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.isWhere = @"5";
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"zhonglei"] integerValue] == 0) {
        WaterViewController *deblocking = [[WaterViewController alloc]init];
        [self.navigationController pushViewController:deblocking animated:YES];
    }else{
        if (indexPath.row <4) {
            [[NSUserDefaults standardUserDefaults]setObject:@"0" forKey:@"gutiyeti"];
        }else{
            [[NSUserDefaults standardUserDefaults]setObject:@"1" forKey:@"gutiyeti"];
        }
        MaterialViewController *deblocking = [[MaterialViewController alloc]init];
        [self.navigationController pushViewController:deblocking animated:YES];
    }
}


#pragma mark - 返回
-(void)clickBackBtn{
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.isWhere = @"3";
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
